//
//  NetworkUtil.h
//  mytianya
//
//  Created by jiao qiang on 10-6-28.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface NetworkUtil : NSObject {
	
	NSURLConnection*	connection;
	NSMutableData*		recvData;
	NSString*			loginCookie;
	
	id			parentDelegate;
	SEL			onCompleteCallback;
	SEL			onErrorCallBack;
	
	
	long long   bytesReceived;
    long long   expectedBytes;
	float	    degreeReceived;
	
	BOOL		isSucess;
	BOOL		beTerminated;
}

@property(nonatomic, retain) NSURLConnection *connection;
@property(nonatomic, retain) NSMutableData *recvData;
@property (nonatomic,retain) NSString *loginCookie;
@property  BOOL beTerminated;


- (id) initWithURL:(NSURL*)url withOperation:(NSString*)operation withDelegate:(id)sender onComplete:(SEL)callback onError:(SEL)err_callback;
- (id) initPostWithURL:(NSURL*)url  body:(NSString*)body withOperation:(NSString *)operation withDelegate:(id)sender onComplete:(SEL)callback onError:(SEL)err_callback;

- (void)terminate;
- (BOOL) isSucess;

- (NSData *)dataFromData:(NSData *)data withEncoding:(NSString *)encoding;
- (NSData*) getUTF8Data:(NSData *)data;
- (NSString*) getResponse;

@end
